

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    music:Object,
    index:Number,
    playingId:Number,
    list:Array
  },


  data: {
   musiclist:[]
  },
  observers:{
    ['list'](data){
      for(let i = 0;i<data.length;i++){
        let artists = data[i].artists;
        if(Array.isArray(artists)){
          data[i].artists = this.formatArtist(artists);
        }
       }
      
       this.setData({
         musiclist:data
       })
    }
    
  },

  
  methods: {
   //选中高亮并跳转播放页面
   onSelect(event){
    let ds = event.currentTarget.dataset;
    this.setData({
      playingId: ds.musicid
    })
    // app.setplayMusicId(this.data.playingId)
    wx.navigateTo({
      url: `/pages/player/player?musicId=${ds.musicid}&index=${ds.index}&playlistId=${ds.playlistid}`,
    })
  },
       formatArtist(arr){
            let artStr='';
            for(let j = 0; j<arr.length;j++){
              artStr += arr[j].name+'/'
            }
            artStr =artStr.slice(0,artStr.length-1)
          return artStr
        },
  }
})
